<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <span>porxy</span>
    <template id='a'>
        <style>
            img{
                width: 100px;
                border-radius: 20px;
            }
        </style>
        <img src="https://semantic-ui.com/images/avatar2/large/kristy.png" alt="">
       
    </template>    
    <first-el></first-el>
</body>

</html>
<!-- <script src="./obj.js"></script> -->
<!-- <script src="./fun.js"></script> -->
<script>
    class UserCard extends HTMLElement {
        constructor() {
            super();
            let aNode = document.getElementById("a");
            let image = aNode.content.cloneNode(true);

            // 隐藏内部first-el代码
            let shadowEl = this.attachShadow({mode:"open"});
            shadowEl.appendChild(image);
        }
    };
    window.customElements.define('first-el', UserCard);
    console.log(UserCard);
</script>